<?php


// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define path to classes directory
defined('CLASSES_PATH') || define('CLASSES_PATH', realpath(dirname(__FILE__) . '/../library/general/classes'));

// Define path to Zend directory
defined('ZEND_PATH') || define('ZEND_PATH', realpath(dirname(__FILE__) . '/../library/Zend'));

// Define path to functions directory
defined('FUNCTIONS_PATH') || define('FUNCTIONS_PATH', realpath(dirname(__FILE__) . '/../library/general/functions'));

// Define path to library directory
defined('LIBRARY_PATH') || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));

// Define path to configuration files directory
defined('CONFIG_PATH') || define('CONFIG_PATH', realpath(dirname(__FILE__) . '/../application/configs'));

// Define application environment
include FUNCTIONS_PATH.'/server_environment.php';
defined('APPLICATION_ENV') || define('APPLICATION_ENV', get_server_environment());

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(LIBRARY_PATH),
    realpath(APPLICATION_PATH),
    get_include_path(),
)));

include FUNCTIONS_PATH.'/auto_version.php';
require_once 'Zend/Db.php';  

require_once 'Zend/Config/Ini.php';  
$config = new Zend_Config_Ini(CONFIG_PATH.'/application.ini', APPLICATION_ENV);

// Set default Timezone
date_default_timezone_set($config->settings->defaulttimezone);  
//die(date('P'));

require_once 'Zend/Registry.php';  
//		Usando registry como singleton
//$registry = new Zend_Registry(array('config' => $config));
//Zend_Registry::setInstance($registry);
Zend_Registry::set('config',$config);


// Create application, bootstrap, and run
require_once 'Zend/Application.php';  
$application = new Zend_Application(
    APPLICATION_ENV, 
   CONFIG_PATH.'/application.ini'
);


include 'general/classes/class.CheckSession.php';

Zend_Controller_Action_HelperBroker::addHelper(new CheckSession());

$application->bootstrap()
            ->run();